# class Solution(object):
#     def longestCommonPrefix(self, strs):
#         """
#         :type strs: List[str]
#         :rtype: str
#         """
#         if strs==None:
#             return ""
#         pre=strs[0]
#         i=1
#         for i in strs:
#             while i[:len(pre)]!=pre:
#                 pre=pre[:-1]
#                 if pre==None:
#                     return ""
#         return pre
# solution=Solution()
# s=["flower","flow","flight"]
# print(solution.longestCommonPrefix(s))
# #length=min(map(len,strs))
# #str=""存放耿工前缀
# #for i in range(length):
#      #letter=strs[0][i]
#      #flag=True
#      #for m in strs[1::]:
#         # if letter!=map:
#         #     flag=False
#         #     break

class Solution(object):
    def longestCommonPrefix(self, strs):
        if strs==None:
            return ""
        for i in range(len(strs[0])):
            pre=strs[0][i]
            for j in range(1,len(strs)):
                if i>=len(strs[j]) or strs[j][i]!=pre:
                    return strs[0][:i]
        return strs[0]
solution=Solution()
s=["flower","flow","flight"]
print(solution.longestCommonPrefix(s))

